﻿#region Using directives

using System;


#endregion

namespace Prologis.ShifterNT {


    public class Field : ICloneable, IKey {

        //public int Index { get; set; }
        public string Name { get; set; }
        public string Source { get; set; }
        public int Pos { get; set; }
        public int Length { get; set; }
        //public bool IsKey { get; set; }
        public bool Enabled { get; set; }
        public object Value { get; set; }
        public object Default { get; set; }
        public bool Flexible { get; set; }
        //public bool IsString { get; set; } 

   
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="source"></param>
        /// <param name="pos"></param>
        /// <param name="length"></param>
        /// <param name="isKey"></param>
        /// <param name="enabled"></param>
        /// 
        //public Field(int index, string name, string source, int pos, int length, bool isKey, bool enabled, object defolt, bool isString) {
        //    Index = index;
        //    Name = name;
        //    Source = source;
        //    Pos = pos;
        //    Length = length;
        //    IsKey = isKey;
        //    Enabled = enabled;
        //    Default = defolt;
        //    IsString = isString;
        //}


        public Field(string name, string source, int pos, int length, bool enabled, object defolt)
        {
            //Index = index;
            Name = name;
            Source = source;
            Pos = pos;
            Length = length;
            //IsKey = isKey;
            Enabled = enabled;
            Default = defolt;
            //IsString = isString;
        }



        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <param name="name"></param>
        /// 
        //public Field(int index, string name): this(index, name, string.Empty, 0, 0, false, true, null, true) {
        //}

        public Field(string name)
            : this(name, string.Empty, 0, 0, true, null)
        {
        }
        

            //Name = name;
            //Source = source;
            //Pos = pos;
            //Length = length;
            //Enabled = enabled;
            //Default = defolt;



        /// <summary>
        /// 
        /// </summary>
        /// 
        //public Field(): this(-1, string.Empty, string.Empty, 0, 0, false, true, null, true) {
        //}

        public Field()
            : this(string.Empty, string.Empty, 0, 0, true, null)
        {
        }
        
        
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        /// 
        //public new string ToString()
        //{
        //    string val = Value != null ? Value.ToString() : "null";
        //    return "Index=" + Index + " Name=" + Name + " Value=" + val + " Source=" + Source + " Pos=" + Pos + " Length=" + Length + " IsKey=" + IsKey + " Enabled=" + Enabled + " Default=" + Default;
        //}


        public new string ToString()
        {
            string val = Value != null ? Value.ToString() : "null";
            return " Name=" + Name + " Value=" + val + " Source=" + Source + " Pos=" + Pos + " Length=" + Length + " Enabled=" + Enabled + " Default=" + Default;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        /// 
        public object Clone() {
            Field field = new Field();
            //field.Index = Index;
            field.Name = this.Name;
            field.Source = this.Source;
            field.Pos = this.Pos;
            field.Length = this.Length;
            //field.IsKey = IsKey;
            field.Enabled = this.Enabled;
            field.Value = this.Value;
            field.Flexible = this.Flexible;
            field.Default = this.Default;
            //field.IsString = IsString;
            return field;
        }


        public string Key {
            get { return Name; }
        }
            
            
            
            
            
    }


}
